package com.tony.demo.ui.performance.xnyh.memory;

import androidx.annotation.IntDef;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 尽量不使用枚举类型
 */
public class Shape {
    public static final int ONE = 1;
    public static final int TWO = 1 << 1;
    public static final int THREE = 3;
    public static final int FOUR = 1 << 2;

    @Model
    private int shape = ONE;

    //flag值为true的话，则表示可取value里面的一个值；false表示只能取value里的多个值，用或符号“|”连接
    @IntDef(flag = true, value = {Shape.ONE, Shape.TWO, Shape.THREE, Shape.FOUR})
    @Retention(RetentionPolicy.SOURCE)
    @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
    public @interface Model {

    }

    public void setShape(@Model int value) {
        this.shape = value;
    }

    @Model
    public int getShape() {
        return shape;
    }
}
